package com.zou.practice.mybatis;

import com.zou.practice.entity.TestObject;
import com.zou.practice.mapper.TestMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author zouyaowen
 * @date 2020-08-22
 */
public class MybatisStudy {
    public static void main(String[] args) throws IOException {
        InputStream is = Resources.getResourceAsStream("mybatis_config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        TestMapper testMapper = sqlSession.getMapper(TestMapper.class);
        TestObject testObject = testMapper.getObject("testCode1");
        System.out.println(testObject.getCode());
    }
}
